<%@ taglib uri="webwork" prefix="webwork"%>
<%@ taglib uri="webwork" prefix="ui"%>
<%@ taglib uri="sitemesh-page" prefix="page"%>

<%@ page import="com.atlassian.jira.util.EasyList"%>
<%@ page import="com.atlassian.jira.web.action.util.JiraLicenseUtils"%>
<%@ page import="com.atlassian.license.License"%>
<%@ page import="com.atlassian.license.LicenseManager"%>

<html>
<head>
<title><webwork:text name="'portal.configure'" /></title>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
	<tr>
		<td width="200" bgcolor="#f0f0f0" valign="top"><jsp:include
			page="/includes/panels/user_summary_pane.jsp" /></td>

		<td bgcolor="#ffffff" valign="top">
		<table width=100% cellpadding="10" cellspacing="0" border="0">
			<tr>
				<td><page:applyDecorator name="jirapanel">
					<page:param name="title">
						<webwork:text name="'portal.configure'" />
					</page:param>
					<page:param name="width">100%</page:param>
					<page:param name="helpURL">configure_portal_pages</page:param>
					<p><webwork:text
						name="'configureportalpages.description.line1'" /><br />
					<webwork:text name="'configureportalpages.description.line2'">
						<webwork:param name="'value0'">
							<span class="warning">
						</webwork:param>
						<webwork:param name="'value1'">
							</span>
						</webwork:param>
					</webwork:text></p>
					<p><img
						src="<webwork:url page="/images/icons/bullet_creme.gif"/>"
						height="8" width="8" border="0" alt="">&nbsp;<a
						href="<webwork:url page="RestoreDefaultDashboard!default.jspa"><webwork:param name="'destination'" value="'manageportal'"/></webwork:url>"><webwork:text
						name="'restoredefaultdashboard.restoredefaults'" /></a></p>
				</page:applyDecorator> <webwork:if test="/currentPortalPage/default == false">
					<br />

					<table align="center" bgcolor="#bbbbbb" border="0" cellpadding="0"
						cellspacing="0" width="90%">
						<tr>
							<td>
							<table id="ownPortalPages" border="0" cellpadding="3" cellspacing="1" width=100%>
								<tr bgcolor="#f0f0f0">
									<td class="colHeaderLink"><b><webwork:text
										name="'manageportalpages.your'" /></b></td>
									<td>&nbsp;</td>
									<td class="colHeaderLink"><b><webwork:text
										name="'manageportalpages.sharing'" /></b></td>
									<td class="colHeaderLink"><b><webwork:text
										name="'common.words.operations'" /></b></td>
								</tr>

								<webwork:iterator value="/ownDashboardPages" status="'status'">
									<tr bgcolor="#<webwork:if test=" @status/modulus(2) ==1">ffffff</webwork:if><webwork:else>fffff0</webwork:else>">
                    <td valign="top">
                        <b><a href="<%= request.getContextPath() %>/secure/Dashboard.jspa?selectPageId=<webwork:property value="./id"/>"><webwork:if test="pageName == 'dashboard'"><webwork:text name="'common.concepts.dashboard'" /></webwork:if><webwork:else><webwork:property value="pageName" /></webwork:else></a></b>
                        <webwork:if test="/currentPortalPage/id == ./id">
                            <span class="smallgrey"><webwork:text name="'configureportalpages.currentpage'"/></span>
                        </webwork:if>
                        <webwork:if test="description && description/length > 0">
                            <br/>
                            <webwork:property value="description"/>
                        </webwork:if>
                    </td>
                    <td width="1%" nowrap>
                        <webwork:if test="@status/first == false">
                        <a id="pos_first_<webwork:property value="@status/index" />" href="ConfigurePortalPages!moveToStart.jspa?position=<webwork:url value="@status/index"/>"><img src="<%= request.getContextPath() %>/images/icons/first.gif"  class="sortArrow" title="<webwork:text name="'configureportalpages.movepage.first'"/>" alt="<webwork:text name="'configureportalpages.movepage.first'"/>"></a>
                        <a id="pos_up_<webwork:property value="@status/index" />" href="ConfigurePortalPages!moveUp.jspa?position=<webwork:url value="@status/index"/>"><img src="<%= request.getContextPath() %>/images/icons/up.gif" class="sortArrow" title="<webwork:text name="'configureportalpages.movepage.up'"/>" alt="<webwork:text name="'configureportalpages.movepage.up'"/>"></a></webwork:if>
                        <webwork:else><img src="<%= request.getContextPath() %>/images/border/spacer.gif" class="sortArrow" alt=""><img src="<%= request.getContextPath() %>/images/border/spacer.gif" class="sortArrow" alt=""></webwork:else>
                        <webwork:if test="@status/last != true">
                        <a id="pos_down_<webwork:property value="@status/index" />" href="ConfigurePortalPages!moveDown.jspa?position=<webwork:url value="@status/index"/>"><img src="<%= request.getContextPath() %>/images/icons/down.gif" class="sortArrow" title="<webwork:text name="'configureportalpages.movepage.down'"/>" alt="<webwork:text name="'configureportalpages.movepage.down'"/>"></a>
                        <a id="pos_last_<webwork:property value="@status/index" />" href="ConfigurePortalPages!moveToEnd.jspa?position=<webwork:url value="@status/index"/>"><img src="<%= request.getContextPath() %>/images/icons/last.gif" class="sortArrow" title="<webwork:text name="'configureportalpages.movepage.last'"/>" alt="<webwork:text name="'configureportalpages.movepage.last'"/>"></a></webwork:if>
                        <webwork:else><img src="<%= request.getContextPath() %>/images/border/spacer.gif" class="sortArrow" alt=""><img src="<%= request.getContextPath() %>/images/border/spacer.gif" class="sortArrow" alt=""></webwork:else>
                    </td>
                    <td>
                    	<table cellpadding=0 cellspacing=0 border=0><tr>
                    	<td>
                    		<webwork:if test="./shared == false">
							<img src="<%= request.getContextPath() %>/images/icons/filter_private.gif" hspace="1" height="16" width="16" border="0" align="absmiddle" alt="<webwork:text name="'manageportalpages.privateportalpage'"/>" title="<webwork:text name="'manageportalpages.privateportalpage'"/>" />
							</webwork:if>
							<webwork:else>
							<img src="<%= request.getContextPath() %>/images/icons/filter_public.gif" hspace="1" height="16" width="16" border="0" align="absmiddle" alt="<webwork:text name="'manageportalpages.sharedportalpage'"/>" title="<webwork:text name="'manageportalpages.sharedportalpage'"/>" />
							</webwork:else>
                    	</td>
	                    <td>
	                        <webwork:if test="./shared == false" >
	                        	<webwork:text name="'manageportalpages.private'"/>
	                        </webwork:if>
	                        <webwork:else>
	                        	<webwork:if test="./group == null" >
	                        		<webwork:text name="'manageportalpages.global'"/>
	                        	</webwork:if>
	                        	<webwork:else>
	                        		<webwork:text name="'manageportalpages.group'"/>: <webwork:property value="./group"/>
	                        	</webwork:else>
	                        </webwork:else>
	                    </td>
	                    </tr></table>
					</td>
                    <td valign="top" nowrap>
                        <a id="config_<webwork:property value="@status/index" />" href="DashboardConfig!default.jspa?selectPageId=<webwork:property value="./id"/>"><webwork:text name="'configureportalpages.fullconfigure'"/></a>
                        <webwork:if test="pageName != 'dashboard'">
                        | <a id="edit_<webwork:property value="@status/index" />" href="EditPortalPage!default.jspa?pageId=<webwork:property value="./id"/>"><webwork:text name="'common.words.edit'"/></a>
                        | <a id="delete_<webwork:property value="@status/index" />" href="ConfigurePortalPages!delete.jspa?pageId=<webwork:property value="./id"/>"><webwork:text name="'common.words.delete'"/></a>
                        </webwork:if>
                        | <a id="share_<webwork:property value="@status/index" />" href="SharePortalPage!default.jspa?pageId=<webwork:property value="./id"/>"><webwork:text name="'manageportalpages.share'"/></a>
                    </td>
                </tr>
								</webwork:iterator>
							</table>
							</td>
						</tr>
					</table>

					<br />

					<table align="center" bgcolor="#bbbbbb" border="0" cellpadding="0"
						cellspacing="0" width="90%">
						<tr>
							<td>
							<table id="viewablePortalPages" border="0" cellpadding="3" cellspacing="1" width=100%>
								<tr bgcolor="#f0f0f0">
									<td class="colHeaderLink"><b><webwork:text
										name="'manageportalpages.viewable'" /></b></td>
									<td class="colHeaderLink"><b><webwork:text
										name="'manageportalpages.sharing'" /></b></td>
									<td class="colHeaderLink"><b><webwork:text
										name="'common.words.operations'" /></b></td>
									<td class="colHeaderLink"><b><webwork:text
										name="'manageportalpages.author'" /></b></td>
								</tr>

								<webwork:if
									test="/sharedDashboardPages != null && /sharedDashboardPages/size > 0">
									<webwork:iterator value="/sharedDashboardPages" status="'status'">
										<tr bgcolor="#<webwork:if test=" @status/modulus(2) ==1">ffffff</webwork:if><webwork:else>fffff0</webwork:else>">
								<td valign="top"><b><a
									href="<%= request.getContextPath() %>/secure/Dashboard.jspa?selectPageId=<webwork:property value="./id"/>"><webwork:if
									test="pageName == 'dashboard'">
									<webwork:text name="'common.concepts.dashboard'" />
								</webwork:if><webwork:else>
									<webwork:property value="pageName" />
								</webwork:else></a></b> <webwork:if test="/currentPortalPage/id == ./id">
									<span class="smallgrey"><webwork:text
										name="'configureportalpages.currentpage'" /></span>
								</webwork:if> <webwork:if test="description && description/length > 0">
									<br />
									<webwork:property value="description" />
								</webwork:if></td>
								<td>
								<table cellpadding=0 cellspacing=0 border=0>
									<tr>
										<td>
				                    		<webwork:if test="./shared == false">
											<img src="<%= request.getContextPath() %>/images/icons/filter_private.gif" hspace="1" height="16" width="16" border="0" align="absmiddle" alt="<webwork:text name="'manageportalpages.privateportalpage'"/>" title="<webwork:text name="'manageportalpages.privateportalpage'"/>" />
											</webwork:if>
											<webwork:else>
											<img src="<%= request.getContextPath() %>/images/icons/filter_public.gif" hspace="1" height="16" width="16" border="0" align="absmiddle" alt="<webwork:text name="'manageportalpages.sharedportalpage'"/>" title="<webwork:text name="'manageportalpages.sharedportalpage'"/>" />
											</webwork:else>
				                    	</td>
					                    <td>
					                        <webwork:if test="./shared == false" >
					                        	<webwork:text name="'manageportalpages.private'"/>
					                        </webwork:if>
					                        <webwork:else>
					                        	<webwork:if test="./group == null" >
					                        		<webwork:text name="'manageportalpages.global'"/>
					                        	</webwork:if>
					                        	<webwork:else>
					                        		<webwork:text name="'manageportalpages.group'"/>: <webwork:property value="./group"/>
					                        	</webwork:else>
					                        </webwork:else>
					                    </td>
									</tr>
								</table>
								</td>
								<td valign="top" nowrap>&nbsp;</td>
								<td><webwork:property value="./author/fullName" /></td>
								</tr>
								</webwork:iterator>
								</webwork:if>
								<webwork:else>
									<tr>
										<td colspan="4" bgcolor="#ffffff"><webwork:text
											name="'manageportalpages.noshared'" /></td>
									</tr>
								</webwork:else>
							</table>
							</td>
						</tr>
					</table>

					<br />
					<%
    License license = LicenseManager.getInstance().getLicense(JiraLicenseUtils.JIRA_LICENSE_KEY);
    if (license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_PROFESSIONAL_LEVEL, JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL)))
    {
%>
					<br />
					<page:applyDecorator name="jiraform">
						<page:param name="action">ConfigurePortalPages.jspa</page:param>
						<page:param name="submitName">
							<webwork:text name="'common.forms.add'" />
						</page:param>
						<page:param name="title">
							<webwork:text name="'configureportalpages.addpage'" />
						</page:param>
						<page:param name="width">90%</page:param>
						<ui:textfield label="/text('common.words.name')"
							name="'addPageName'" size="'30'">
							<ui:param name="'mandatory'">true</ui:param>
						</ui:textfield>

						<ui:textfield label="/text('common.words.description')"
							name="'description'" size="'60'" />

						<%--
	        				Following condition is temporary workaround for functional tests because selectOption functionality
	        				from Atlassian funtional test support does not work
	        			--%>
						<% if(System.getProperties().containsKey("functional.tests")) { %>
							<tr>
				        		<td class="fieldLabelArea"><webwork:text name="'configureportalpages.startfrom'" /></td>
				        		<td bgcolor="ffffff" class="fieldValueArea">
				        			<input name="copyPageId" type="text">
				        		</td>
				        	</tr>
						<% } else { %>
							<ui:select label="/text('configureportalpages.startfrom')"
								name="'copyPageId'" list="dashboardPages" listKey="'id'"
								listValue="'/pageName(.)'">
								<ui:param name="'headerrow'">
									<webwork:text name="'configureportalpages.blankpage'" />
								</ui:param>
								<ui:param name="'description'">
									<webwork:text
										name="'configureportalpages.blankpage.description'" />
								</ui:param>
							</ui:select>
						<% } %>
					</page:applyDecorator>
					<%
					}
					%>
				</webwork:if></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</body>
</html>